import 'package:flutter/material.dart';
import 'package:ichinesereader/controller/reports.dart';
import 'package:get/get.dart';
import 'package:ichinesereader/pages/teacher/quickReviewOverviewCharts.dart';
import 'package:ichinesereader/pages/teacher/quickReviewOverviewList.dart';
import 'package:ichinesereader/utils/log.dart';
import 'package:hive_flutter/hive_flutter.dart';
import '../../themes/appTheme.dart';

class SkillBuildingQuickReview extends StatefulWidget {
  SkillBuildingQuickReview({Key? key}) : super(key: key);

  @override
  SkillBuildingQuickReviewState createState() =>
      SkillBuildingQuickReviewState();
}

class SkillBuildingQuickReviewState extends State<SkillBuildingQuickReview> {
  final ReportsController controller = Get.find();
  final box = Hive.box('appconfig');
  String mode = 'list';

  @override
  void initState() {
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
  }

  buildFloatingActionButtons() {
    return Column(mainAxisAlignment: MainAxisAlignment.center, children: [
      Padding(
          padding: const EdgeInsets.only(bottom: 8.0),
          child: SizedBox(
            width: 45.0,
            height: 45.0,
            child: FloatingActionButton(
              backgroundColor: Get.isDarkMode
                  ? Get.theme.primaryColorDark
                  : AppTheme.colors.pinkBtn,
              foregroundColor:
                  Get.isDarkMode ? Colors.black : AppTheme.colors.lightPink,
              heroTag: "Check Graph",
              tooltip: "Check Graph",
              onPressed: () {
                var toggleMode = mode == "graph" ? "list" : "graph";
                setState(() {
                  mode = toggleMode;
                });
              },
              elevation: 5,
              splashColor: Colors.grey,
              child: Icon(Icons.timeline),
            ),
          ))
    ]);
  }

  @override
  Widget build(BuildContext context) {
    Log.debug('Build skill building quick review');
    return Scaffold(
        floatingActionButton: buildFloatingActionButtons(),
        floatingActionButtonLocation: FloatingActionButtonLocation.miniEndTop,
        backgroundColor: Colors.transparent,
        body: mode == "graph"
            ? SingleChildScrollView(
                scrollDirection: Axis.vertical,
                primary: false,
                child: Container(
                  decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(3.0),
                      color: Get.isDarkMode
                          ? AppTheme.colors.darkTheme2
                          : Colors.white.withOpacity(0.3)),
                  child: Column(
                    mainAxisSize: MainAxisSize.max,
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [QuickReviewOverviewCharts()],
                  ),
                ),
              )
            : Container(
                decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(3.0),
                    color: Get.isDarkMode
                        ? AppTheme.colors.darkTheme2
                        : Colors.white.withOpacity(0.3)),
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: [QuickReviewOverviewList()],
                ),
              ));
  }
}
